﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;
using System.Drawing;

namespace KP_CommonLibrary.KP_CommonControls.NumericInput
{
   public class DXMouseEventArgs : HandledMouseEventArgs
{
    // Fields
    private HandledMouseEventArgs original;

    // Methods
    protected DXMouseEventArgs(HandledMouseEventArgs e) : base(e.Button, e.Clicks, e.X, e.Y, e.Delta, e.Handled)
    {
        this.original = e;
        this.Sync();
    }

    public DXMouseEventArgs(MouseButtons buttons, int clicks, int x, int y, int delta) : this(buttons, clicks, x, y, delta, false)
    {
    }

    public DXMouseEventArgs(MouseButtons buttons, int clicks, int x, int y, int delta, bool handled) : base(buttons, clicks, x, y, delta, handled)
    {
    }

    public static DXMouseEventArgs GetMouseArgs(MouseEventArgs eventArgs)
    {
        return GetMouseArgs(null, eventArgs);
    }

    public static DXMouseEventArgs GetMouseArgs(Control control, EventArgs eventArgs)
    {
        DXMouseEventArgs args = eventArgs as DXMouseEventArgs;
        if (args != null)
        {
            return args;
        }
        HandledMouseEventArgs e = eventArgs as HandledMouseEventArgs;
        MouseEventArgs args3 = eventArgs as MouseEventArgs;
        if (args3 == null)
        {
            Point mousePosition = Control.MousePosition;
            if ((control != null) && control.IsHandleCreated)
            {
                mousePosition = control.PointToClient(mousePosition);
            }
            args3 = new MouseEventArgs(Control.MouseButtons, 1, mousePosition.X, mousePosition.Y, 0);
        }
        if (e != null)
        {
            return new DXMouseEventArgs(e);
        }
        return new DXMouseEventArgs(args3.Button, args3.Clicks, args3.X, args3.Y, args3.Delta);
    }

    [EditorBrowsable(EditorBrowsableState.Never)]
    public void Sync()
    {
        if (this.original != null)
        {
            this.original.Handled = base.Handled;
        }
    }

    // Properties
    public new bool Handled
    {
        get
        {
            this.Sync();
            return base.Handled;
        }
        set
        {
            base.Handled = value;
            this.Sync();
        }
    }
}

 

}
